<script language='javascript'>
var controller = '{$smarty.get.controller}';
{literal}
$(function(){
    //全选
    $("#checkedAll").click(function(){
        $("input[name='chk[]']").each(function(i){
            $(this).click();
        });
    });
    

    $('#save2').click(function(){
        //2016-12-5 by jeff,3秒内disabled
        var _this = this;
        $(_this).text('保存中').attr('disabled',true);
        setTimeout(function(){
            $(_this).text('保存').attr('disabled',false);
        },3000);
        // return false;
        var ck = $('[name="chk[]"]:checked');   //选择器
        //将所有的选中的id用,连接后传递
        var id=[];
        var danjia=[];
        var money=[];
        var _money=[];
        ck.each(function(){
            id.push($(this).val());
            var trs = $(this).parents('tr');
            danjia.push($('[name="danjia[]"]',trs).val());        
            money.push($('[name="money[]"]',trs).val());
        });
        if(id.length==0) {
            alert('请选择过账信息!');
            return false;
        }
        //只能点击一次保存按钮
        $('#save2').attr("disabled","disabled");
        var url="?controller="+controller+"&action=Save";
        var str = JSON.stringify(id);
        var param={ids:str,danjia:danjia,money:money};

        $.getJSON(url,param,function(json){
             if(json==true){
                alert('保存成功');
             }
            window.location.reload();
         });
    });
});
{/literal}
</script>
